using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class ChoosedPawn : MonoBehaviour, IPointerClickHandler
{
    public ChooseWindow window;
    public Pawn Pawn;
    public Image image;
    public GameObject Frame;
    public Status status;
    public GetPawnProperty getPawnProperty;
    public void SetPawn(Pawn pawn)
    {
        Pawn = pawn;
        var carddata = pawn.TestCardData;
        image.sprite = Pawn.gameObject.GetComponentInChildren<SpriteRenderer>().sprite;
        getPawnProperty.UpdateProperty(carddata.HealPoint, carddata.Attack, carddata.Defence);

    }

    public void OnPointerClick(PointerEventData eventData)
    {
        window.OnSelectPawn(this);
    }

    public void ShowFrame(bool ifShow)
    {
        Frame.SetActive(ifShow);
        status.gameObject.SetActive(ifShow);
        status.ShowStatus(Pawn);
    }

    public void Reset()
    {
        Pawn = null;
        image.sprite = null;
        ShowFrame(false);
    }
}
